package optimalServerSpaceCalculation;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class optimalSpaceServerCalculationVersion2 {
	
	public static void main(String args[]){
		int startingSrcFrgNum = 90;
		int endingSrcFrgNum = 95;
		
		int startingWastage = 150;
		int endingWastage = 1000;
		
		int USERDEFINED_N=200;
		
		StartingSourceFragHelper helper = new StartingSourceFragHelper();
//		TreeMap<Integer, Double> frgSpace = new TreeMap<Integer, Double>();
//		TreeMap<Integer, Integer> frgServer = new TreeMap<Integer, Integer>();
		
		ParametersTupleComparator com  = new ParametersTupleComparator();
		List<ParametersTuple> selectionParameters = new ArrayList<ParametersTuple>();
		
		ServerParameterTupleComparator com2 = new ServerParameterTupleComparator();
		
		
		for (int i = startingSrcFrgNum; i <= endingSrcFrgNum; i++){
			List<ParametersTuple> tempParameters = new ArrayList<ParametersTuple>();
			System.out.println(i);
			for( int j=startingWastage;j<endingWastage;j++){
				
				double cummSpace= helper.calculateCumSpace(i, j);
				int numOfServers=helper.calculateMaxServer();
				System.out.println("cummSpace"+cummSpace+"numOfServers"+numOfServers);
//				frgSpace.put(i, helper.calculateCumSpace(i,j));
//				frgServer.put(i, helper.calculateMaxServer());
				if( (numOfServers<USERDEFINED_N+10)){
					tempParameters.add( new ParametersTuple(i,j, cummSpace, numOfServers));
				}
				
			}
			if(tempParameters.size()!=0){
			Collections.sort(tempParameters,com);
			selectionParameters.add(tempParameters.get(0));
			System.out.println(tempParameters.get(0));
			tempParameters=null;
			}
		}
		
		Collections.sort(selectionParameters,com2);	
		System.out.println("parameters+ servers+wastage");
		if(selectionParameters.size()!=0){
		System.out.println(selectionParameters.get(0));
		}
	}

}
